package com.atguigu.cmsservice.controller;


import com.atguigu.cmsservice.entity.CrmBanner;
import com.atguigu.cmsservice.service.CrmBannerService;
import com.atguigu.commonutils.R;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.Cacheable;

import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 * 首页banner表 前端控制器
 * </p>
 *
 * @author huangqicai
 * @since 2022-10-25
 */
@RestController
@RequestMapping("/cmsservice/frontBanner")
//原来需要在Controller上面加上@CrossOrigin解决跨域问题，现在gateway已经处理了
@Api(description = "前台banner列表")
public class BannerFrontController {

    @Autowired
    private CrmBannerService crmBannerService;

    /*前台直接查询所有的banner*/
    @ApiOperation(value = "前台显示所有的banner")
    @PostMapping("/getAllBanner")
    public R getAllBanner(){
        List<CrmBanner> list=crmBannerService.getAllBanner();
        if(list.size()>0){
            return R.ok().data("list", list);
        }
        return R.error();
    }

}

